﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Xml;
using System.Xml.Serialization;

namespace Crawler
{
    #region Word Class

    [Serializable]
    public class Word
    {
        #region Private fields
        private Hashtable files = new Hashtable();
        #endregion

        #region Properties
        [XmlElement("t")]
        public string Text
        { get; set; }

        [XmlElement("fs")]
        public File[] Files
        {
            get
            {
                File[] fileArray = new File[files.Count];
                files.Values.CopyTo(fileArray, 0);
                return fileArray;
            }
            set
            {
                File[] fileArray = value;
                Hashtable index = new Hashtable();
            }
        }
        #endregion

        #region Constructors
        public Word() { }

        public Word(string text, File file)
        {
            this.Text = text;

            files.Add(file.Url, file);
        }
        #endregion

        #region Members
        public void Add(File file)
        {
            if (files.ContainsKey(file.Url))
            {
                ((File)files[file.Url]).Hits++;
            }
            else
            {
                files.Add(file.Url, file);
            }
        }
        #endregion
    }
    #endregion
}
